﻿<%@ Page Title="Saved Reports" Language="C#" MasterPageFile="~/DeveloperSite.Master" AutoEventWireup="true" 
    CodeBehind="Saved_Projects.aspx.cs" Inherits="UNDP_Projects.Project.Saved_Projects" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <asp:EntityDataSource ID="SavedProjectsDataSource" runat="server" 
        ConnectionString="name=UNDPEntities" DefaultContainerName="UNDPEntities" 
        EnableDelete="True" EnableFlattening="False" EnableInsert="True" 
        EnableUpdate="True" EntitySetName="project_reports" 
        Include="year, report_period, project" 
        AutoGenerateWhereClause="true">
        <WhereParameters>
            <asp:Parameter DefaultValue="true" Name="saved" Type="Boolean" />
        </WhereParameters>
    </asp:EntityDataSource>

    <%--<p>--%>
    <asp:Label ID="ContextLabel" runat="server" Text="SAVED PROJECT REPORTS" CssClass="ContentHead"></asp:Label>
    <br />
    <asp:Label ID="Error" runat="server" Text="" Visible="false" CssClass="ErrorText" ForeColor="Red"></asp:Label>
    
    <%--</p>--%>
    
    <% if (User.IsInRole("Administrator"))
       { %>
    <asp:GridView ID="SavedProjectsGridView" runat="server" 
        AutoGenerateColumns="False" CssClass="NewGrid" 
        OnRowCommand="SavedProjectsGridView_RowCommand"
        OnRowDataBound="SavedProjectsGridView_RowDataBound" 
        ShowFooter="True" 
        DataSourceID="SavedProjectsDataSource" 
        DataKeyNames="project_id, year_id, report_period_id">
        <AlternatingRowStyle CssClass="NewGridAlt" />
        <FooterStyle CssClass="NewGridFooter" />
        <Columns>
            <asp:TemplateField HeaderText="YEAR">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("year.year1") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="QUARTER">
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("report_period.report_period1") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="PROJECT" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="400px">
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("project.project1") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>

             <asp:ButtonField ButtonType="Button" CommandName="access" Text="Access" HeaderText="DATA ENTRY" />
             <asp:ButtonField ButtonType="Button" CommandName="pdf" Text="PDF" HeaderText="DOWNLOAD" />
             <%--<asp:ButtonField ButtonType="Button" CommandName="delete" Text="Delete" HeaderText="DELETE" />--%>
             <asp:CommandField ShowDeleteButton="true" ButtonType="Button" HeaderText="DELETE" />
        </Columns>
    </asp:GridView>
    <% }
       else if (User.IsInRole("project"))
       { %>
       
       <asp:GridView ID="SavedProjectsGridView1" runat="server" 
        AutoGenerateColumns="False" CssClass="NewGrid" 
        OnRowCommand="SavedProjectsGridView_RowCommand" ShowFooter="True" 
        DataSourceID="SavedProjectsDataSource" 
        DataKeyNames="project_id,year_id,report_period_id">
        <AlternatingRowStyle CssClass="NewGridAlt" />
        <FooterStyle CssClass="NewGridFooter" />
        <Columns>
            <asp:TemplateField HeaderText="YEAR">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("year.year1") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="QUARTER">
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("report_period.report_period1") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="PROJECT" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="400px">
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("project.project1") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Left" Width="400px"></ItemStyle>
            </asp:TemplateField>

             <asp:ButtonField ButtonType="Button" CommandName="access" Text="Access" HeaderText="DATA ENTRY" />
             <asp:ButtonField ButtonType="Button" CommandName="pdf" Text="PDF" HeaderText="DOWNLOAD" />
             <%--<asp:ButtonField ButtonType="Button" CommandName="delete" Text="Delete" HeaderText="DELETE" />--%>
             <asp:TemplateField HeaderText="DELETE" ShowHeader="False">
                 <ItemTemplate>
                     <asp:Button ID="Button1" runat="server" CausesValidation="False" 
                         CommandName="Delete" Text="Delete" Enabled="false" />
                 </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
       
       <% }
       else
       { %>
        <asp:GridView ID="SavedProjectsGridView2" runat="server"
        AutoGenerateColumns="False" CssClass="NewGrid" OnRowCommand="SavedProjectsGridView_RowCommand"
        ShowFooter="True" DataSourceID="SavedProjectsDataSource"
        DataKeyNames="project_id,year_id,report_period_id">
        <AlternatingRowStyle CssClass="NewGridAlt" />
        <FooterStyle CssClass="NewGridFooter" />
        <Columns>
            <asp:TemplateField HeaderText="YEAR">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("year.year1") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="QUARTER">
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("report_period.report_period1") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="PROJECT" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="400px">
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("project.project1") %>'></asp:Label>
                </ItemTemplate>

<ItemStyle HorizontalAlign="Left" Width="400px"></ItemStyle>
            </asp:TemplateField>
             <%--<asp:ButtonField ButtonType="Button" CommandName="delete" Text="Delete" HeaderText="DELETE" />--%>
             <asp:TemplateField HeaderText="DATA ENTRY" ShowHeader="False">
                 <ItemTemplate>
                     <asp:Button ID="Button2" runat="server" CausesValidation="false" 
                         CommandName="access" Text="Access" Enabled="false" />
                 </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="DOWNLOAD" ShowHeader="False">
                <ItemTemplate>
                    <asp:Button ID="Button3" runat="server" CausesValidation="false" 
                        CommandName="pdf" Text="PDF" Enabled="false" />
                </ItemTemplate>
            </asp:TemplateField>
             <asp:TemplateField HeaderText="DELETE" ShowHeader="False">
                 <ItemTemplate>
                     <asp:Button ID="Button1" runat="server" CausesValidation="False" 
                         CommandName="Delete" Text="Delete" Enabled="false" />
                 </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        </asp:GridView>
       <% } %>
    <%--<p>
        <asp:Label ID="ProjectLabel" runat="server" Text=""></asp:Label><br />
        <asp:Label ID="ReportPeriodLabel" runat="server" Text=""></asp:Label><br />
        <asp:Label ID="YearLabel" runat="server" Text=""></asp:Label>
    </p>--%>
</asp:Content>
